import React from 'react';
import { connect } from 'umi';
// import { history } from 'umi';
import { get as getPath } from 'object-path';
import { Form, Tabs } from 'antd';
// import { TablePagination } from 'vv-frontend-components';
// import { formatMessage } from 'umi';
// import moment from 'moment';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
// import DataPick2 from '@/components/DatePicker2';
// import Locale from '@/utils/locale';

import { withRoutePage } from '@/utils/enhanceUtils';
import MissList from './MissList';
import LateList from './LateList';
import AbsenceList from './AbsenceList';

class Abnormal extends React.Component {
    componentDidMount() {}

    changeTab = () => {
        // const { dispatch, abnormal } = this.props;
        // dispatch({
        //     type: 'abnormal/save',
        //     payload: {
        //         pagination: {
        //             ...abnormal.pagination,
        //             current: 1,
        //             pageSize: 10
        //         }
        //     }
        // });
    };

    render() {
        const { TabPane } = Tabs;
        let defaultDate;
        if (getPath(this.props, 'location.query.date') && getPath(this.props, 'location.query.date') !== 'undefined') {
            defaultDate = getPath(this.props, 'location.query.date');
        }
        return (
            <PageHeaderWrapper>
                <Tabs
                    size="large"
                    defaultActiveKey={getPath(this.props, 'location.query.key', 'misslist')}
                    tabBarStyle={{ margin: 0 }}
                    style={{ background: '#fff', padding: '0 24px' }}
                    onChange={this.changeTab}
                >
                    <TabPane key="misslist" tab="缺卡记录">
                        <MissList date={getPath(defaultDate)} />
                    </TabPane>
                    <TabPane key="latelist" tab="迟到早退记录">
                        <LateList date={getPath(defaultDate)} />
                    </TabPane>
                    <TabPane key="absencelist" tab="缺勤记录">
                        <AbsenceList date={getPath(defaultDate)} />
                    </TabPane>
                </Tabs>
            </PageHeaderWrapper>
        );
    }
}
export default withRoutePage(
    connect(({ abnormal, loading }) => ({
        abnormal,
        loading: loading.models.abnormal
    }))(Form.create()(Abnormal))
);
